angular.module('imsApp').controller('creativeDetailController', ['$scope', '$rootScope', '$state', 'CreativesManager', '$sce', function ($scope, $rootScope, $state, CreativesManager, $sce) {
    var creativeId = $state.params.creativeId;
    $scope.$state = $state;
    $scope.$sce = $sce;
    CreativesManager.creativesDetail(creativeId).then(function (result) {
        $scope.creative = result.data;
    });
    $scope.cancel = function() {
            $state.go("campaigns.promotionGroup.creatives",{reload:true});
    };


    $(document).ready(function () {
        myFunction();
        function myFunction() {
            setTimeout(function () {

                $("#audio,#video").addClass('load');
                $('#bg-stop').click(function () {
                    $('#bg-stop').hide();
                    $("#audio").addClass('load');
                    if ($('#audio').hasClass('load')) {
                        $("#audio").trigger("play");
                        $('#audio').removeClass('load');
                        $('#audio').addClass('play');
                    } else {

                    }
                    ;

                })
                $('#video').click(function () {
                    $("#video").addClass('load');
                    $('.bg-stop1').hide();
                    if ($('#video').hasClass('load')) {
                        $("#video").trigger("play");
                        $('#video').removeClass('load');
                        $('#video').addClass('play');
                    } else {

                    }
                    ;

                })
                $("#audio").bind('ended', function () {
                    $('.bg-stop').show();
                });

                $("#video").bind('ended', function () {
                    $('.bg-stop1').show();
                });

            }, 1000);
        }


    })
}])

